package mytest;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import net.sourceforge.opencamera.R;

import java.util.ArrayList;
import java.util.List;

public class UserAlbumsFragment extends Fragment {
    private RecyclerView recyclerView;
    private AlbumAdapter albumAdapter;
    private List<String> albums = new ArrayList<>(); // 相册路径

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_albums, container, false);

        recyclerView = view.findViewById(R.id.recyclerViewalbums);
        recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));  // 2列网格

        loadAlbums();  // 加载相册数据

        albumAdapter = new AlbumAdapter(getContext(), albums);
        recyclerView.setAdapter(albumAdapter);

        return view;
    }

    private void loadAlbums() {
        // 加载用户创建的相册
        albums.add("旅行相册");
        albums.add("家庭相册");
        // 更多相册...
    }

}


